<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>登录</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <link rel="stylesheet" th:href="@{/lib/weui.min.css}">
    <link rel="stylesheet" th:href="@{/css/jquery-weui.css}">
    <link rel="stylesheet" th:href="@{/css/demos.css}">

</head>
<body>
<header class='demos-header'>
    <h1 class="demos-title">登录</h1>
</header>
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">账号</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" id="username" type="text"  placeholder="请输入账号">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" id="password" type="password"  placeholder="请输入密码">
        </div>
    </div>
    <div class="weui-cell">
    </div>

    <div class="weui-msg">
        <div class="weui-msg__opr-area">
            <p class="weui-btn-area">
                <a href="javascript:loginHtml();" class="weui-btn weui-btn_primary">登录</a>
            </p>
        </div>
    </div>
</div>
</body>
<script th:src="@{/lib/jquery-2.1.4.js}"></script>
<script th:src="@{/lib/fastclick.js}"></script>
<script th:src="@{/js/jquery-weui.js}"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
    });
    function loginHtml(){
        var username = $("#username").val();
        if(username == null || username == "" || username == undefined){
            $.toast("帐号不能为空！", "cancel");
            return
        }
        var password = $("#password").val();
        if(password == null || password == "" || password == undefined){
            $.toast("密码不能为空！", "cancel");
            return
        }

        $.get("/coupon/offcialAccount/login",{username:username,password:password},function(res){
            if(res.code == 200){
                window.location.href="/coupon/offcialAccount/payHtml?token="+res.result;
            }else{
                $.toast("账号或密码错误", "cancel");
            }
        })
    }
    /*function setText(number){

        number = number-1;
        if(number > 0){
            $("#smsId").text(number +"(秒)")
            $("#smsId").attr("disabled","disabled");
            setTimeout("setText("+number+")",1000);
        }else{
            $("#smsId").text("获取验证码")
            $("#smsId").removeAttr("disabled")
        }
    }
    function savePhone(){
        var phone = $("#phone").val();
        var code = $("#code").val();
        var openId = $("#openId").val();
        var appId = $("#appId").val();
        $.post("/center/savePhone",{phone:phone,code:code,openId:openId,appId:appId},function(res){
            if(res.code == 200){
                window.location.href="/center/regist";
            }else{
                $.toast(res.message, "forbidden");
            }
        })
    }*/
</script>
</html>